package acs.bridge;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;


import java.io.IOException;
import java.io.InputStream;

/**
 * ACS
 * User: stas
 * Date: 16.05.13
 * Time: 22:34
 */

public class StreamXmlApplicationContext extends AbstractXmlApplicationContext {

    private Resource[] configResources = null;

    public StreamXmlApplicationContext(InputStream configFileStream){
        super();
        this.configResources = new Resource[]{new InputStreamResource(configFileStream)} ;
        this.refresh();
    }
    @Override
    protected Resource[] getConfigResources() {
        return this.configResources;
    }

    @Override
    public  void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException {
        reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
        super.loadBeanDefinitions(reader);
    }
}